<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/sys/include/taglib.jsp"%>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>农产品质量安全追溯系统 - 名优产品</title>
    <link rel="stylesheet" href="${path}/cms/css/public.css"/>
    <link rel="stylesheet" href="${path}/cms/css/qualityProducts.css"/>
    <script type="text/javascript" src="${path}/cms/js/jquery-1.8.3.min.js"></script>
    <script type="text/javascript" src="${path}/cms/js/js.js"></script>
    <script type="text/javascript" src="${path}/cms/js/qualityProducts.js"></script>

</head>
<body>
<%@ include file="/WEB-INF/cms/header.jsp" %>

<article class="htmleaf-container">
    <div class="tabs">
        <div class="tabs-header">
            <div class="border"></div>
            <ul>
                <li class="active"><a style="cursor:pointer" onclick="setType(6)">全部产品</a></li>
                <li><a style="cursor:pointer" onclick="setType(0)" >名优特色产品</a></li>
                <li><a style="cursor:pointer" onclick="setType(1)" >有机农产品</a></li>
                <li><a style="cursor:pointer" onclick="setType(2)" >绿色食品</a></li>
                <li><a style="cursor:pointer" onclick="setType(3)" >无公害农产品</a></li>
            </ul>
        </div>
        <div class="tabs-content">
            <div class="active">
            	<ul class="tabsContentUl" id="datalist">
                   
                 </ul>
                <div class="bottomBlank"></div>
            </div>
        </div>
    </div>
    <div class="pageBox">
	    <div class="counter" id="pageCounter"></div>
	    <button class="paginate left" id="pagePrev"><i></i><i></i></button>
	    <button class="paginate right" id="pageNext"><i></i><i></i></button>
	</div>
</article>
<%@ include file="/WEB-INF/cms/footer.jsp" %>
<script src="${path }/res/js/myutils.js"></script>
<script type="text/javascript">
var pagePrev, pageNext, pageCounter, pageNo=1, pageCount=10000,type=6;
$(function(){
	pagePrev = $('#pagePrev');
	pagePrev.click(function(){
		if(pageNo<=1){
			pageNo = 1;
		}else{
			pageNo--;
		}
		loadPage(pageNo);
	});
	pageNext = $('#pageNext');
	pageNext.click(function(){
		if(pageNo>=pageCount){
			pageNo = pageCount;
		}else{
			pageNo++;
		}
		loadPage(pageNo);
	});
	pageCounter = $('#pageCounter');
	loadPage(1);
});
function setType(type1){
	type = type1;
	loadPage(1);
}
function loadPage(pageNo){
	$.get("${path}/c/list_products.json?page="+pageNo+"&type="+type,function(page){
		pageNo = page.pageNo;
		pageCount = page.totalPage;
		pageCounter.html(pageNo+" / "+pageCount);
		pagePrev[0].setAttribute('data-state', pageNo<=1 ? 'disabled' : '');
		pageNext[0].setAttribute('data-state', pageNo>=pageCount ? 'disabled' : '');
		var list = page.rows;//获取list
	    var listStr = ""; //要拼接的字符串
	    //循环遍历list
	    for(var i=0;i<list.length;i++){
	    	var timetext = formatDate(list[i].identificationTime, "yyyy-MM-dd");
	    	listStr += '<li><div><a href="${path}/c/pdtDetail.do?id='+list[i].productid+'"><div class="MyPic">';
	    	if(list[i].identification != ''){
	    		listStr += '<img src="${path}/cms/images/mypic5.png" alt="">';
	    	}
	    	listStr += '</div>';
	    	listStr += '<img src="${filepath}/wellproduct_img/'+list[i].productImg+'" alt="" onerror="this.src=\'${path}/cms/def/pdt.png\'"></a></div><div><a href="${path}/c/pdtDetail.do?id='+list[i].productid+'"><h3>'+list[i].productName+'</h3></a><p>产地：'+list[i].parkName+'</p>';
	    	if(list[i].identificationTime != null){
	    		listStr += '<p>认证时间：'+timetext+'</p></div></li>';
	    	}
	    }
	    $('#datalist').empty().append(listStr);
	});
}
</script>
</body>
</html>